import React from "react";
import Link from "umi/link";
import queryString from 'query-string';
import { getTableProps } from "components/searchTable/SearchTable.jsx";

export  function getFormConfig() {
  return [
    { label: "任务名称", key: "taskName" },
    { label: "流程名称", key: "modelName" },
    { label: "申请人",   key: "applyUserName" },
    { label: "流程单号", key: "serialNum" },
  ];
}

export function getTableColumns() {
  return [
			{
				title: "序号",
				dataIndex: "processInstanceId",
				render: (value, record, index) => {
          const { page: {  pageNum, pageSize } } = this.state;
					return (pageNum - 1) * pageSize + index + 1;
				},
			},
			{ title: "任务名称", dataIndex: "taskName" },
			{ title: "流程名称", dataIndex: "modelName" },
			{ title: "流程单号", dataIndex: "serialNum" },
			{
				title: "状态",
				dataIndex: "status",
				render: value => value === "TODO" ? "待处理" : "已完成",
			},
			{ title: "申请时间", dataIndex: "applyTime" },
			{ title: "申请人", dataIndex: "applyUserName" },
			{
				title: "操作",
				dataIndex: "claim",
        render: (value, record) => (
          <Link
            to={{
              pathname: "/taskcenter/detail",
              search: queryString.stringify({
                processInstanceId: record.processInstanceId,
                actype: "processed",
              }),
            }}
          >
            详情
          </Link>
        ),
			},
	 ];
}
export function getAntTableProps() {
  const { page: { pageNum, pageSize } } = this.state;
  const { processedData, loading } = this.props;
  const { datas = [], totalCount } = processedData; 
  return getTableProps({
    rowKey: "taskId",
    columns: this.getTableColumns(),
    dataSource: datas,
    loading: loading.effects["FlowHandle/getProProcessedNew"],
    pagination: {
      current: pageNum,
      pageSize,
      total: totalCount,
      onChange: this.handlePageChange,
      onShowSizeChange: this.handlePageChange,
    },
  });
}
